package com.huice.huiceprovider.controller;

import com.huice.huiceprovider.codegen.tables.S1User;
import com.huice.huiceprovider.codegen.tables.records.S1UserRecord;
import com.huice.huiceprovider.dao.UserDao;
import com.huice.huiceprovider.entity.vo.UserVo;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description TODO
 * @Author 赵凯
 * @Date 2021/7/14 13:13
 **/
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Autowired
    UserDao userDao;


    @GetMapping("provideName")
    public String provideName() {
        return "罗老师";
    }

    @RequestMapping("insert")
    public int insertUser() {
        int primaryId = userDao.insert();
        return primaryId;
    }

    @GetMapping("delete/{id}")
    public int deleteUser(@PathVariable int id){
        return userDao.delete(id);
    }

    @GetMapping("update")
    public int updateUser(){
        return userDao.update();
    }

    @GetMapping("/select/{id}")
    public List<UserVo> selectUserd(@PathVariable int id) {
        List<UserVo> records = userDao.select(id);
        System.out.println(records);
        return records;
    }


}
